---
title: anthropic
---


The `anthropic` provider supports all APIs that use the same interface for the `/v1/messages` endpoint.

Example:
```baml BAML
client<llm> MyClient {
  provider anthropic
  options {
    model "claude-sonnet-4-20250514"
    temperature 0
  }
}
```

## BAML-specific request `options`
These unique parameters (aka `options`) modify the API request sent to the provider.

You can use this to modify the `headers` and `base_url` for example.

<ParamField
  path="api_key"
  type="string"
>
  Will be passed as a bearer token. **Default: `env.ANTHROPIC_API_KEY`**
  
  `Authorization: Bearer $api_key`
</ParamField>

<ParamField
  path="base_url"
  type="string"
>
  The base URL for the API. **Default: `https://api.anthropic.com`**
</ParamField>

<ParamField path="headers" type="object">
  Additional headers to send with the request.

  Unless specified with a different value, we inject in the following headers:
  ```
  "anthropic-version" "2023-06-01"
  ```

Example:
```baml
client<llm> MyClient {
  provider anthropic
  options {
    api_key env.MY_ANTHROPIC_KEY
    model "claude-sonnet-4-20250514"
    headers {
      "X-My-Header" "my-value"
    }
  }
}
```
</ParamField>

<Markdown src="/snippets/role-selection.mdx" />

<Markdown src="/snippets/allowed-role-metadata.mdx" />

<Markdown src="/snippets/supports-streaming.mdx" />

<Markdown src="/snippets/finish-reason.mdx" />

<Markdown src="/snippets/media-url-handler.mdx" />

<Note>
  Anthropic's default behavior is to convert PDFs to base64 (`send_base64`) while keeping other media types as URLs (`send_url`). This is because Anthropic's API requires PDFs to be base64-encoded.
</Note>

## Provider request parameters
These are other parameters that are passed through to the provider, without modification by BAML. For example if the request has a `temperature` field, you can define it in the client here so every call has that set.

Consult the specific provider's documentation for more information.
<ParamField
   path="system"
   type="DO NOT USE"
>
  BAML will auto construct this field for you from the prompt, if necessary.
  Only the first system message will be used, all subsequent ones will be cast to the `assistant` role.
</ParamField>

<ParamField
   path="messages"
   type="DO NOT USE"
>
  BAML will auto construct this field for you from the prompt
</ParamField>

<ParamField
   path="stream"
   type="DO NOT USE"
>
  BAML will auto construct this field for you based on how you call the client in your code
</ParamField>

<ParamField
  path="model"
  type="string"
>
  The model to use.

| Model | Use Case | Release | Context | Features |
|-------|----------|---------|---------|----------|
| **claude-opus-4-1-20250805** | Complex coding, AI agents | Aug 2025 | 200K | Most powerful reasoning |
| **claude-sonnet-4-20250514** | Default choice, versatile | May 2025 | 200K-1M | Hybrid reasoning modes |
| **claude-3-5-haiku-20241022** | Fast, cost-efficient | Oct 2024 | 200K | Speed optimized |  

<img src="https://mintlify.s3-us-west-1.amazonaws.com/anthropic/images/3-5-sonnet-curve.png" />

See anthropic docs for the latest list of all models. You can pass any model name you wish, we will not check if it exists.
</ParamField>

<ParamField path="max_tokens" type="int">
  The maximum number of tokens to generate. **Default: `4069`**
</ParamField>


For all other options, see the [official anthropic API documentation](https://docs.anthropic.com/en/api/messages).